package com.fhz.shop.di;

import android.content.Context;

import androidx.room.Room;


import com.fhz.shop.dao.SearchDao;
import com.fhz.shop.util.AppDataBase;

import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;
import dagger.hilt.InstallIn;
import dagger.hilt.android.qualifiers.ApplicationContext;
import dagger.hilt.components.SingletonComponent;

/**
 * 时间:2023/8/19
 *
 * @author Mr.Feng
 * 简述:
 */
@Module
@InstallIn(SingletonComponent.class)
public class DataBaseModule {

    @Provides
    @Singleton
    public SearchDao getGoodsInfoDao(AppDataBase appDataBase){
        return appDataBase.mSearchDao();
    }

    @Singleton
    @Provides
    public AppDataBase getDataBase(@ApplicationContext Context context){
        return Room.databaseBuilder(context, AppDataBase.class, "a2102shop")
                .allowMainThreadQueries()
                .build();
    }
}   
